package cn.edu.njpi.three;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

public class Main {
    public static void main(String[] args) {
//        利用Thread重写run方法来实现
//        new PrintThread("Good!").start();
//        new PrintThread("Nice!").start();
//        Thread t = new PrintThread("Year！");
//        t.start();
//        利用Runnable接口实现run方法来实现
//        new Thread(new Printer("Good!")).start();
//        new Thread(new Printer("Nice!")).start();
//        Runnable r = new Printer("Year!");
//        Thread t = new Thread(r);
//        t.start();
//        利用ThreadFactory启动新线程
        ThreadFactory factory = Executors.defaultThreadFactory();
        factory.newThread(new Printer("Nice!")).start();
        for (int i = 0; i < 10000; i++) {
            System.out.print("Good!");
        }
    }
}
